package com.job.common.asserts;

import com.job.common.exception.CityIsNullException;
import com.job.common.exception.ParameterIsNullException;
import com.job.common.exception.ProvinceIsNullException;
import com.job.pojo.City;
import com.job.pojo.Province;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.Objects;

public class MyAssert {

    public static void objectParameterCheck(Object obj) throws ParameterIsNullException {
        if (Objects.isNull(obj)){
            throw new ParameterIsNullException("入参为空，请求失败");
        }
    }

    public static void ProvinceCheck(List<Province> provinces) throws ProvinceIsNullException {
        if (Objects.isNull(provinces) || CollectionUtils.isEmpty(provinces)){
            throw new ProvinceIsNullException("无法查找省记录，待网络健康后重试，请求失败");
        }
    }

    public static void CityCheck(List<City> cities) throws CityIsNullException {
        if (Objects.isNull(cities) || CollectionUtils.isEmpty(cities)){
            throw new CityIsNullException("无法根据用户提供的省id查找到对于的市，该省id不存在");
        }
    }

//    public static void checkId(Integer id) throws  UserException {
//        User user = userMapper.selectById(id);
//        if (Objects.isNull(user)){
//            throw  new UserException("用户不存在");
//        }
//    }

}
